<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload file test</title>

<script src="servicemonitor.swf" type="application/x-shockwave-flash" />
<script type="text/javascript" src="AIRAliases.js"></script>
<script>


	var url = new air.URLRequest("http://www.blogbus.com/user/login.php");
	var loader = new air.URLLoader();

	url.method =  air.URLRequestMethod.POST;
	url.data = "username=jiee2008&password=history";
	//url.requestHeaders = ;	
	
	loader.addEventListener(air.Event.COMPLETE, loadComplete);
	loader.load( url );	

function loadComplete( event )  {

	var url = new air.URLRequest("http://file.home.blogbus.com/");
	var loader = new air.URLLoader();
	airReferer = new air.URLRequestHeader("Referer","http://www.blogbus.com/user/");
	url.requestHeaders = new Array(airReferer);
	loader.addEventListener(air.Event.COMPLETE, function() {
					var url2 = new air.URLRequest("http://file.home.blogbus.com/documents/1792454/upload");
					url2.method =  air.URLRequestMethod.POST;
					var file = air.File.desktopDirectory.resolvePath('F-1.jpg');
					file.addEventListener(air.Event.COMPLETE, function() {alert("finished!")}); 
					file.upload(url2);						 				 
														 });
	loader.load(url);
	//alert(loader.data);
	//var url2 = new air.URLRequest("http://file.home.blogbus.com/documents/1792454/upload");
	//var loader = new air.URLLoader();
	
	//fileData = new air.ByteArray();

	//var stream = new air.FileStream();
	//stream.open(file,air.FileMode.READ);
	//stream.readBytes(fileData);,
	//stream.close();
	//alert(fileData.length);
	//url.data = fileData;
	//airReferer = new air.URLRequestHeader("Referer","http://file.home.blogbus.com/");
	//airContentType = new air.URLRequestHeader("Content-Type","application/octet-stream");
	//airHost = new air.URLRequestHeader("host","file.home.blogbus.com");
	//url.requestHeaders = new Array(airReferer,airContentType,airHost);
	
	//loader.addEventListener(air.Event.COMPLETE, function() {alert(loader.data);});
	//loader.load(url);
}

</script>
</head>

<body>
</body>
</html>
